←︎ Back Business Forecasting › Class Slides
1 / 23

Time Series Patterns & Graphics

Lecture 2

What patterns should we look for in a time series?

What patterns should we look for in a time series?

Trend — a long-run upward or downward movement.
  • Global temperatures have trended upward over decades.
  • A trend need not be linear; it can accelerate or reverse over time.

What patterns should we look for in a time series?

Trend — a long-run upward or downward movement.
  • Global temperatures have trended upward over decades.
  • A trend need not be linear; it can accelerate or reverse over time.
Seasonality — regular, calendar-driven fluctuations.
  • Retail sales spike every December; electricity demand peaks every summer.
  • The period is fixed and known: daily, weekly, monthly, or annual.

What patterns should we look for in a time series?

Trend — a long-run upward or downward movement.
  • Global temperatures have trended upward over decades.
Seasonality — regular, calendar-driven fluctuations.
  • Retail sales spike every December; electricity demand peaks every summer.
Cycles — longer irregular waves not tied to a calendar.
  • Business cycles typically last 2–10 years but have no fixed period.
  • Unlike seasonality, cycles cannot be predicted by the calendar alone.
Remainder — random, unexplained variation.
  • What is left after accounting for trend, seasonality, and cycles.
Seasonality and cycles are easy to confuse — but they differ fundamentally.
Seasonality has a fixed, known period tied to the calendar. You can look at a date and know which part of the seasonal pattern applies.
Cycles have variable length and are driven by economic or business forces, not the calendar. Their peaks and troughs cannot be predicted from dates alone.
Many real series contain both: housing starts have a seasonal pattern (more construction in spring/summer) and a business cycle component that can stretch or compress over years.

Why should you always plot your data before fitting a model?

Always look before you model.

Plots reveal patterns invisible in summary statistics.
  • Trend, seasonality, structural breaks, and outliers all show up visually.
  • Anscombe’s Quartet: four datasets with identical means and variances but completely different shapes.
Graphics guide model selection.
  • A strongly trended series may need differencing; a seasonal series needs a seasonal model.
  • Applying the wrong model wastes effort and produces bad forecasts.
Key plot types in fpp3.
  • Time plot (autoplot()), seasonal plot (gg_season()), seasonal subseries plot (gg_subseries()), lag plot (gg_lag()), ACF plot (ACF() |> autoplot()).
The time plot is always the first step.
Plot the variable on the vertical axis against time on the horizontal axis. In R: autoplot(data, variable).
What to look for:
  • Direction and shape of any trend (linear, accelerating, reversing).
  • Seasonal spikes: do they repeat at the same time each year?
  • Outliers and structural breaks: sudden jumps or shifts in level.
  • Changing variance: does the spread of the series grow over time? (If so, a log transformation may help.)
Seasonal plots overlay each year to show the seasonal pattern clearly.
gg_season(data, variable) plots each year (or season) as a separate line against the sub-annual time axis (months, weeks, etc.).
This makes it easy to see:
  • Whether the seasonal pattern is stable across years or has shifted over time.
  • Which months or quarters are systematically high or low.
  • Whether the peak month has drifted (e.g., holiday shopping starting earlier).
gg_subseries() adds the mean for each sub-period as a horizontal line, making level differences across seasons even more explicit.

What is autocorrelation, and why does it matter for forecasting?

Autocorrelation measures how a series correlates with its own past.
The autocorrelation at lag k is:
rk = Corr(yt, yt−k)
r1 > 0: today’s value predicts tomorrow’s — common in trended series.
rs large (where s is the seasonal period): the series repeats each season.
Autocorrelation is the foundation of ARIMA models: if the past predicts the future, we can exploit that structure.
The correlogram (ACF plot) displays rk for each lag.
Reading the correlogram:
  • Slowly decaying positive bars → trend in the series.
  • Spikes at lags 12, 24, 36… → annual seasonality in monthly data.
  • All bars near zero → white noise; the past carries no information about the future.
Stylized ACF — trended series (slow decay)
White noise is a series with no autocorrelation.
Formally: yt = εt, where εt ∼ iid(0, σ²). Each observation is an independent random draw.
In a white noise ACF, all bars should lie within the 95% critical bounds ±1.96/√T. Bars outside the bounds suggest exploitable structure.
Why it matters: if the residuals from your model are white noise, you have captured all the forecastable structure. If they are not, the model is missing something.
Lag plots show the relationship between yt and yt−k visually.
gg_lag(data, variable, lags = 1:9) produces a scatter plot grid of the series against its own lagged values.
A strong positive linear relationship at lag 1 confirms high r1 — the series has momentum. A pattern at lag 12 confirms annual seasonality in monthly data.
Lag plots also reveal non-linear dependence that the ACF (a linear measure) would miss.

How do we formally separate trend, seasonality, and remainder?

Decomposition splits a series into its components.
Additive decomposition — appropriate when the seasonal variation is roughly constant in size:
yt = Tt + St + Rt
Multiplicative decomposition — appropriate when seasonal swings grow proportionally with the level of the series:
yt = Tt × St × Rt
A multiplicative series can usually be converted to additive by taking logarithms: log(yt) = log(Tt) + log(St) + log(Rt).
STL is the most flexible decomposition method.
STL stands for Seasonal and Trend decomposition using Loess. In R: STL(variable ~ trend() + season()).
Advantages over classical decomposition:
  • Handles any seasonal period (not just monthly or quarterly).
  • The seasonal component can change slowly over time.
  • Robust to outliers — extreme values do not distort the trend.
Seasonally adjusted data = ytSt (additive). Removes seasonal noise to reveal the underlying trend and cycle more clearly.
Transformations stabilize variance and simplify patterns.
When a series has variance that grows with its level, a log transformation often produces a more stable series that is easier to model.
TransformationUse when…
NoneVariance appears constant over time
Square rootVariance grows slowly with level
log(y)Variance grows proportionally with level (most common)
Box-Cox (λ)Generalizes the above; choose λ to minimize variation
Forecasts must be back-transformed to the original scale for interpretation. Back-transforming a log forecast gives the median forecast, not the mean.

A complete graphical analysis workflow

1. Time plot — identify trend, seasonality, outliers, variance changes.
  • Transform the data if variance is non-constant.
2. Seasonal plot — confirm the seasonal pattern and its stability.
  • Use gg_season() and gg_subseries().
3. Lag plot and ACF — quantify autocorrelation structure.
  • ACF slowly decaying → trend; spikes at multiples of s → seasonality.
4. STL decomposition — isolate each component for closer inspection.
  • Check whether the remainder looks like white noise.
In R, time series data is stored in a tsibble.
A tsibble (time series tibble) is the fpp3 data format. It requires a time index and, for panel data, a key variable identifying each series.
Creating a tsibble:
as_tsibble(df, index = date, key = region)
The time index determines the frequency (daily, monthly, quarterly, annual) and enables all fpp3 plotting and modelling functions to work automatically with the correct time scale.
Practice Questions
Question 1 of 4

Key Terms